package com.yunquan.ohana.http

import com.yunquan.ohana.entity.ContactEntity
import com.yunquan.ohana.entity.FileEntity
import com.yunquan.ohana.entity.FramesEntity
import com.yunquan.ohana.entity.GroupFramesEntity
import com.yunquan.ohana.entity.HistoryEntity
import com.yunquan.ohana.entity.HomeInformationModel
import com.yunquan.ohana.entity.ListsEntity
import com.yunquan.ohana.entity.ListsItemEntity
import com.yunquan.ohana.entity.LoginEntity
import com.yunquan.ohana.entity.LoginV2Entity
import com.yunquan.ohana.entity.RoleEntity
import com.yunquan.ohana.entity.ScheduleModel
import com.yunquan.ohana.entity.TaskEntity
import com.yunquan.ohana.entity.UserEntity
import com.yunquan.ohana.entity.WeatherEntity
import com.yunquan.ohana.entity.WeatherHistoryEntity
import com.yunquan.ohana.http.transformer.BasePage
import com.yunquan.ohana.http.transformer.BaseResult
import io.reactivex.rxjava3.core.Observable
import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Query
import retrofit2.http.Streaming
import retrofit2.http.Url

interface ApiService {
    @Streaming
    @GET
    fun downloadFile(@Url url: String): Observable<ResponseBody>

    /**
     * 设备登录
     */
    @POST("/album/appUser/loginEmail")
    fun appLogin(@Body body: RequestBody): Observable<BaseResult<LoginV2Entity>>

    /**
     * 注销用户
     */
    @POST("/album/appUser/cancelEmail")
    fun deleteUser(): Observable<BaseResult<Boolean>>

    /**
     * 游客模式登录
     */
    @POST("/album/appUser/touristLogin")
    fun touristLogin(@Body body: RequestBody): Observable<BaseResult<LoginEntity>>

    /**
     * 发送重置邮件
     */
    @POST("/album/appUser/sendPasswordResetEmail")
    fun sendPasswordResetEmail(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 获取用户信息
     */
    @GET("/album/appUser/getAppUser")
    fun getAppUser(): Observable<BaseResult<UserEntity>>

    /**
     * 编辑用户信息
     */
    @POST("/album/appUser/updateAppUser")
    fun updateAppUser(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 发送邮箱验证码
     */
    @POST("/album/appUser/sendEmailCode")
    fun sendEmailCode(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 绑定邮箱
     */
    @POST("/album/appUser/bindEmail")
    fun bindEmail(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 绑定设备
     */
    @POST("/album/userDeviceRelation/bindDevice")
    fun bindDevice(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 解绑设备
     */
    @POST("/album/userDeviceRelation/unbindDevice")
    fun unbindDevice(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 获取绑定设备列表
     */
    @POST("/album/userDeviceRelation/getUserDeviceList")
    fun getUserDeviceList(@Body body: RequestBody): Observable<BaseResult<List<FramesEntity>>>

    /**
     * 发送到相册
     */
    @POST("/album/userTrends/saveUserTrendsList")
    fun sendToAlbum(@Body body: RequestBody): Observable<BaseResult<String>>

    /**
     * 删除相册数据
     */
    @POST("/album/userTrends/deleteGroupUserTrends")
    fun deleteGroupUserTrends(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 相册列表
     */
    @POST("/album/userTrends/getUserTrendsGroupPage")
    fun getUserTrendsGroupPage(@Body body: RequestBody): Observable<BaseResult<BasePage<HistoryEntity>>>

    /**
     * 相册-获取设备列表
     */
    @POST("/album/userTrends/getGroupDeviceList")
    fun getGroupDeviceList(@Body body: RequestBody): Observable<BaseResult<List<GroupFramesEntity>>>

    /**
     * 获取平台联系方式
     */
    @GET("/album/platform/getContactInformation")
    fun getContactInformation(): Observable<BaseResult<ContactEntity>>

    /**
     * 单文件上传
     */
    @Multipart
    @POST("/album/fileSource/upload")
    fun uploadFile(@Query("type") type: Int, @Part file: MultipartBody.Part): Observable<BaseResult<FileEntity>>

    /**
     * 单文件上传
     */
    @Multipart
    @POST("/album/fileSource/upload")
    fun uploadFileSync(@Query("type") type: Int, @Part file: MultipartBody.Part): Call<BaseResult<FileEntity>>

    /**
     * 获取日历首页数据
     */
    @POST("/album/home/getHomeInformation")
    fun homeInformation(@Body body: RequestBody): Observable<BaseResult<HomeInformationModel>>

    /**
     * 创建日程
     */
    @POST("/album/schedule/createSchedule")
    fun createSchedule(@Body body: RequestBody): Observable<BaseResult<ScheduleModel>>

    /**
     * 根据日程id修改日程内容
     */
    @POST("/album/schedule/updateSchedulesById")
    fun updateSchedulesById(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 获取用户当前设备所有日程
     */
    @POST("/album/schedule/getAllSchedulesByDeviceId")
    fun getAllSchedulesByDeviceId(@Body body: RequestBody): Observable<BaseResult<List<ScheduleModel>>>

    /**
     * 根据日程id和设备id逻辑删除日程
     */
    @POST("/album/schedule/deleteSchedule")
    fun deleteSchedule(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 日程与设备的关联
     */
    @POST("/album/schedule/addSScheduleDeviceRelation")
    fun addSScheduleDeviceRelation(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 安卓第三方日历添加
     */
    @POST("/album//oauth2/android")
    fun uploadEvents(@Body body: RequestBody): Observable<BaseResult<Int>>

    /**
     * 获取当前设备所有任务-查询（）
     */
    @POST("/album/tasks/getTasksByDeviceId")
    fun getTasksByDeviceId(@Body body: RequestBody): Observable<BaseResult<List<TaskEntity>>>

    /**
     * 创建任务
     */
    @POST("/album/tasks/createTasks")
    fun createTasks(@Body body: RequestBody): Observable<BaseResult<TaskEntity>>

    /**
     * 根据任务id修改任务内容
     */
    @POST("/album/tasks/updateTasksById")
    fun updateTasksById(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 根据任务id和设备id逻辑删除任务
     */
    @POST("/album/tasks/deleteTasks")
    fun deleteTasks(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 修改任务完成状态
     */
    @POST("/album/tasks/updateTasksToStautsByDeviceId")
    fun updateTasksToStautsByDeviceId(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 任务与设备的关联
     */
    @POST("/album/tasks/addTasksDeviceRelation")
    fun addTasksDeviceRelation(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 获取当前用户标签组列表
     */
    @POST("/album/lists/getLists")
    fun getListsByDeviceId(@Body body: RequestBody): Observable<BaseResult<List<ListsEntity>>>

    /**
     * 根据标签组id获取标签内容列表
     */
    @POST("/album/lists/getListsContentByListsId")
    fun getListsContentByListsId(@Body body: RequestBody): Observable<BaseResult<List<ListsItemEntity>>>

    /**
     * 新建标签组
     */
    @POST("/album/lists/createLists")
    fun createLists(@Body body: RequestBody): Observable<BaseResult<List<ListsEntity>>>

    /**
     * 删除标签组
     */
    @POST("/album/lists/deleteListsToId")
    fun deleteListsToId(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 新建标签
     */
    @POST("/album/lists/addListsContent")
    fun addListsContent(@Body body: RequestBody): Observable<BaseResult<List<ListsItemEntity>>>

    /**
     * 修改标签信息
     */
    @POST("/album/lists/updateListsContentType")
    fun updateListsContentType(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 删除标签
     */
    @POST("/album/lists/deleteListsContentToId")
    fun deleteListsContentToId(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 关联标签组与设备
     */
    @POST("/album/lists/bindListsToDevice")
    fun bindListsToDevice(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 创建设备角色
     */
    @POST("/album/deviceRole/createDeviceRoleByid")
    fun createDeviceRoleById(@Body body: RequestBody): Observable<BaseResult<RoleEntity>>

    /**
     * 根据角色Id修改信息
     */
    @POST("/album/deviceRole/updateRoleToColor")
    fun updateRoleToColor(@Body body: RequestBody): Observable<BaseResult<Boolean>>

    /**
     * 删除设备角色
     */
    @POST("/album/deviceRole/deleteDeviceRole")
    fun deleteDeviceRole(@Body body: RequestBody): Observable<BaseResult<Int>>

    /**
     * 根据设备id查询角色列表
     */
    @POST("/album/deviceRole/getDeviceRoleListById")
    fun getDeviceRoleListById(@Body body: RequestBody): Observable<BaseResult<List<RoleEntity>>>

    /**
     * 获取城市天气
     */
    @GET("/album/weather/getHourlyAndDaily")
    fun getHourlyAndDaily(
        @Query("location") location: String,
        @Query("lang") lang: String,
    ): Observable<BaseResult<WeatherEntity>>

    /**
     * 获取城市坐标
     */
    @GET("/album/weather/getCityLookup")
    fun getCityLookup(
        @Query("cityName") cityName: String,
    ): Observable<BaseResult<WeatherHistoryEntity>>
}